Use the download module for printing snapshots
authorAlex Crichton <alex@alexcrichton.com>
Wed, 22 Jul 2015 21:33:21 +0000 (14:33 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 22 Jul 2015 21:33:21 +0000 (14:33 -0700)
The script that prints new snapshots for Cargo now uses the same download module
as the rest of Cargo. Also adds a quiet option to suppress printing.

src/etc/download.py
src/etc/print-new-snapshot.py

index 27d4a861fb323ffe3844fbf0d3f6eae6205a52db..2a6636ccf83266c805033827d9d8610301119c1e 100644 (file)
@@ -5,14 +5,14 @@ import subprocess
 import sys
 import tarfile
 
-def get(url, path):
+def get(url, path, quiet=False):
     # see http://serverfault.com/questions/301128/how-to-download
     if sys.platform == 'win32':
         run(["PowerShell.exe", "/nologo", "-Command",
              "(New-Object System.Net.WebClient).DownloadFile('" + url +
-                "', '" + path + "')"])
+                "', '" + path + "')"], quiet=quiet)
     else:
-        run(["curl", "-o", path, url])
+        run(["curl", "-o", path, url], quiet=quiet)
 
 def unpack(tarball, dst, quiet=False):
     if quiet:
index bbb10656324acad462241dee0870e44167e269bd..7f0aff538f3669eb9634d2c797db3b866152defe 100644 (file)
@@ -3,6 +3,7 @@ import os
 import subprocess
 import sys
 import hashlib
+import download
 
 date = sys.argv[1]
 
@@ -24,10 +25,8 @@ snaps = {
 for platform in sorted(snaps):
     triple = snaps[platform]
     tarball = 'cargo-nightly-' + triple + '.tar.gz'
-    url = 'https://static-rust-lang-org.s3.amazonaws.com/cargo-dist/' + date + '/' + tarball
+    url = 'https://static.rust-lang.org/cargo-dist/' + date + '/' + tarball
     dl_path = "target/dl/" + tarball
-    ret = subprocess.call(["curl", "-f", "-s", "-o", dl_path, url])
-    if ret != 0:
-        raise Exception("failed to fetch url")
+    download.get(url, dl_path, quiet = True)
     h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest()
     print('  ' + platform + ' ' + h)